<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择部门领导')"/>
</head>
<body class="gray-bg">
<input type="hidden" id="rowIds">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/user";

    var deptId=[[${deptId}]];
    if (deptId==null){
      deptId="";
    }
    console.log("deptId:",deptId);
    $(function () {
        var options = {
            url: prefix + "/usersOfDept?deptId="+deptId,
            showSearch: false,
            showRefresh: true,
            showToggle: true,
            showColumns: true,
            method: "get",
            columns: [{
                // field: 'state',
                // checkbox: true
                radio: true
            },
                {
                    field: 'userId',
                    title: '用户ID',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '用户名',
                },
                {
                    field: 'dept.deptName',
                    title: '用户所在部门'
                },
                {
                    field: 'loginName',
                    title: '登录名称',
                    sortable: true
                },
                {
                    field: 'postId',
                    title: '岗位ID',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'postName',
                    title: '岗位名称',
                    sortable: true
                },
                {
                    field: 'roleId',
                    title: '角色ID',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'roleName',
                    title: '角色名称',
                    sortable: true
                },
                ]
        };
        $.table.init(options);
    });


    /* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
    function getSelections() {
       var selected= $.table.selectFirstColumns();
        console.log("selected:",selected);
        return selected;
    }

    function getSelections2() {
        var selected2= $.table.selectColumns("userName");
        console.log("selected2:",selected2);
        return selected2;
    }

    $("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
        var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
        var rowIds = $.table.affectedRowIds(rows);
        $("#rowIds").val(rowIds);
    });
</script>
</body>
</html>